{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  孟媛\n",
    "+ 学号  0165339"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "贫困户\n",
      "国家实行义务教育保障\n",
      "国家实行住房安全保障\n",
      "国家实行饮水安全保障\n",
      "国家实行食物安全保障\n",
      "\n",
      "\n",
      "贫困户\n",
      "无需实行义务教育保障\n",
      "无需实行住房安全保障\n",
      "无需实行饮水安全保障\n",
      "国家实行食物安全保障\n",
      "\n",
      "\n",
      "贫困户\n",
      "国家实行义务教育保障\n",
      "无需实行住房安全保障\n",
      "无需实行饮水安全保障\n",
      "国家实行食物安全保障\n"
     ]
    }
   ],
   "source": [
    "class poverty(object):\n",
    "    def __init__(household,a,b,c,d):#0为需要扶贫\n",
    "        household.education=a\n",
    "        household.housing=b\n",
    "        household.drink=c\n",
    "        household.foods=d\n",
    "        sum = household.education+household.housing+household.drink+household.foods\n",
    "        if sum > 3:\n",
    "            print(\"非贫困户\")\n",
    "        else:\n",
    "            print(\"贫困户\")\n",
    "    \n",
    "    def edu(household,teaching):\n",
    "        sum = household.education+household.housing+household.drink+household.foods\n",
    "        if sum > 3:        \n",
    "            print(\"无需扶贫\")\n",
    "        elif household.education == 0 and teaching<9 : #teaching<9意为未达到义务教育标准\n",
    "            print(\"国家实行义务教育保障\")\n",
    "        else :\n",
    "            print(\"无需实行义务教育保障\")       \n",
    "    def hou(household,home):\n",
    "        sum = household.education+household.housing+household.drink+household.foods\n",
    "        if sum > 3:\n",
    "            print(\"无需扶贫\")\n",
    "        elif household.housing == 0 and home <5 :#home<5意为住房不安全\n",
    "            print(\"国家实行住房安全保障\")\n",
    "        else :\n",
    "            print(\"无需实行住房安全保障\")\n",
    "    def dri(household,water):\n",
    "        sum = household.education+household.housing+household.drink+household.foods\n",
    "        if sum > 3:\n",
    "            print(\"无需扶贫\")\n",
    "        elif household.drink==0 and water < 6:#water<6意为饮用水不卫生\n",
    "            print(\"国家实行饮水安全保障\")\n",
    "        else :\n",
    "            print(\"无需实行饮水安全保障\")\n",
    "    def foo(household,crops):\n",
    "        sum = household.education+household.housing+household.drink+household.foods\n",
    "        if sum > 3:\n",
    "            print(\"无需扶贫\")\n",
    "        elif household.foods == 0 and crops < 10:#crops<10意为缺乏肉蛋奶豆\n",
    "            print(\"国家实行食物安全保障\")\n",
    "        else :\n",
    "            print(\"无需实行食物安全保障\")\n",
    "            \n",
    "poverty_1=poverty(0,0,0,0)\n",
    "poverty_1.edu(teaching=0)\n",
    "poverty_1.hou(home=0)\n",
    "poverty_1.dri(water=0)\n",
    "poverty_1.foo(crops=0)\n",
    "print(\"\\n\")\n",
    "poverty_1=poverty(1,0,0,0)\n",
    "poverty_1.edu(teaching=6)\n",
    "poverty_1.hou(home=5)\n",
    "poverty_1.dri(water=7)\n",
    "poverty_1.foo(crops=4)\n",
    "print(\"\\n\")\n",
    "poverty_1=poverty(0,1,0,0)\n",
    "poverty_1.edu(teaching=5)\n",
    "poverty_1.hou(home=5)\n",
    "poverty_1.dri(water=7)\n",
    "poverty_1.foo(crops=4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ABMI可能偏大\n",
      "\n",
      "\n",
      "B体重正常\n",
      "\n",
      "\n",
      "CBMI可能偏大\n"
     ]
    }
   ],
   "source": [
    "class student(object):\n",
    "    def __init__(self,name,score,sleeptime): \n",
    "        self.name = name\n",
    "        self.score = score\n",
    "        self.sleeptime = sleeptime\n",
    "        \n",
    "    def weight(self,figure=90,time=6):\n",
    "        if self.score>figure and self.sleeptime <time :\n",
    "            print(self.name +\"BMI可能偏大\")\n",
    "        else :\n",
    "            print(self.name + \"体重正常\")\n",
    "\n",
    "stu1 = student('A',100,3)\n",
    "stu1.weight(figure=90,time=6)\n",
    "print(\"\\n\")\n",
    "stu2 = student('B',100,3)\n",
    "stu2.weight(figure=110,time=6)\n",
    "print(\"\\n\")\n",
    "stu3 = student('C',100,3)\n",
    "stu3.weight(figure=9,time=9)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A趋向正常\n",
      "\n",
      "\n",
      "B体重正常\n",
      "\n",
      "\n",
      "C趋向正常\n"
     ]
    }
   ],
   "source": [
    "class club(student):\n",
    "    def __init__(self,name,score,sleeptime,runtime): \n",
    "        super().__init__(name,score,sleeptime)\n",
    "        self.runtime=runtime\n",
    "        \n",
    "    def weight(self,figure=90,time=6):\n",
    "        if self.score>figure and self.sleeptime <time and self.runtime > 30:\n",
    "                    print(self.name + \"趋向正常\")\n",
    "        else :\n",
    "            print(self.name + \"体重正常\")\n",
    "\n",
    "stu1 = club('A',100,3,40)\n",
    "stu1.weight(figure=90,time=6)\n",
    "print(\"\\n\")\n",
    "stu2 = club('B',100,3,20)\n",
    "stu2.weight(figure=110,time=6)\n",
    "print(\"\\n\")\n",
    "stu3 = club('C',100,3,40)\n",
    "stu3.weight(figure=9,time=9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
